<%@ page language="java" import="java.sql.*,java.util.ArrayList, java.text.NumberFormat, java.text.DecimalFormat" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class=kontakt>
<br/>
<div class=formularz>
<fieldset class=obrys>	
<%HttpSession sesja = request.getSession(true);
Connection con = mb.commons.DbConnection.getConnection();
Statement stmt = con.createStatement();
ArrayList masa = new ArrayList();
ArrayList ubezpieczenie = new ArrayList();
ArrayList inne = new ArrayList();
NumberFormat format = new DecimalFormat("#0.00");
ResultSet rs = stmt.executeQuery("SELECT min,max,wartosc FROM cennik WHERE opis='masa';");
while(rs.next()){
	masa.add(rs.getDouble("min"));
	masa.add(rs.getDouble("max"));
	masa.add(rs.getDouble("wartosc"));
}
rs = stmt.executeQuery("SELECT min,max,wartosc FROM cennik WHERE opis='ubezpieczenie';");
while(rs.next()){
	ubezpieczenie.add(rs.getDouble("min"));
	ubezpieczenie.add(rs.getDouble("max"));
	ubezpieczenie.add(rs.getDouble("wartosc"));
}
rs = stmt.executeQuery("SELECT opis,wartosc FROM cennik WHERE opis!='masa' AND opis!='ubezpieczenie';");
while(rs.next()){
	inne.add(rs.getString("opis"));
	inne.add(rs.getDouble("wartosc"));
}
if(sesja.getAttribute("lang").equals("en")){
%>
	<img src='images/kasa.png' height=150px width=150px><br/><br/>
	<h1>Current price list for our services:</h1>
	<br><br>
	Charges for shipment (depending on weight):
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black" bgcolor="#BDEDFF"><tr><th width=180px;>Min weight</th><th width=180px;>Max weight</th><th width=180px;>Price (zł)</th></tr><tr>
		<%
		for(int i=0;i<masa.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			out.write(masa.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(masa.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(format.format(Double.parseDouble(masa.get(i).toString())));
			out.write("</td></tr>");
		}
		%>
		</table>
		</td>
	</tr>
	</table>
	<br/><br/>
	Charges for additional services:<Br>
	- insurance (depending on value of the package):<br>
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black" bgcolor="#BDEDFF"><tr><th width=180px;>Min value</th><th width=180px;>Max value</th><th width=180px;>Price (zł)</th></tr><tr>
		<%
		for(int i=0;i<ubezpieczenie.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			out.write(ubezpieczenie.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(ubezpieczenie.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;			
			out.println(format.format(Double.parseDouble(ubezpieczenie.get(i).toString())));
			out.write("</td></tr>");
		}
		%>
		</table>
		</td>
	</tr>
	</table>
	<br/><br/>
	 - charges for other additional services:<br>
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black " bgcolor="#BDEDFF"><tr><th width=180px;>Usługa:</th><th width=180px;>Opłata (zł)</th></tr><tr>
		<%
		for(int i=0;i<inne.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			if(inne.get(i).toString().equals("pobranie")) out.write("Payment by the recipient");
			else if(inne.get(i).toString().equals("pakunek")) out.write("Shipment packaging");
			else if(inne.get(i).toString().equals("dojazd")) out.write("Ordering a courier online");
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.println(format.format(Double.parseDouble(inne.get(i).toString())));
			out.write("</td></tr>");
		}
		%>		
		</table>
		</td>
	</tr>
	</table>	
<%}else{%>
	<img src='images/kasa.png' height=150px width=150px><br/><br/>
	<h1>Aktualny cennik obowiązujący dla naszych usług:</h1>
	<br><br>
	Opłaty za przesyłkę (w zależności od wagi):
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black" bgcolor="#BDEDFF"><tr><th width=180px;>Waga minimalna</th><th width=180px;>Waga maxymalna</th><th width=180px;>Opłata (zł)</th></tr><tr>
		<%
		for(int i=0;i<masa.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			out.write(masa.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(masa.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(format.format(Double.parseDouble(masa.get(i).toString())));
			out.write("</td></tr>");
		}
		%>
		</table>
		</td>
	</tr>
	</table>
	<br/><br/>
	Opłata za usługi dodatkowe:<Br>
	- ubezpieczenie (w zależności od wartości paczki):<br>
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black" bgcolor="#BDEDFF"><tr><th width=180px;>Wartośc min</th><th width=180px;>Wartość max</th><th width=180px;>Opłata (zł)</th></tr><tr>
		<%
		for(int i=0;i<ubezpieczenie.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			out.write(ubezpieczenie.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.write(ubezpieczenie.get(i).toString());
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;			
			out.println(format.format(Double.parseDouble(ubezpieczenie.get(i).toString())));
			out.write("</td></tr>");
		}
		%>
		</table>
		</td>
	</tr>
	</table>
	<br/><br/>
	- opłaty za inne usługi dodatkowe:<br>
	<table class=opcje >
	<tr>
		<td align="center" valign="middle"> 
		<table style="border:solid 1px black " bgcolor="#BDEDFF"><tr><th width=180px;>Usługa:</th><th width=180px;>Opłata (zł)</th></tr><tr>
		<%
		for(int i=0;i<inne.size();i++){
			out.write("<tr bgcolor='#FDEEF4'><td align='center' style='border:solid 1px black'>");
			if(inne.get(i).toString().equals("pobranie")) out.write("Płatność przez odbiorce");
			else if(inne.get(i).toString().equals("pakunek")) out.write("Pakowanie przesyłki");
			else if(inne.get(i).toString().equals("dojazd")) out.write("Zamówienie kuriera online");
			out.write("</td><td align='center' style='border:solid 1px black'>");
			i++;
			out.println(format.format(Double.parseDouble(inne.get(i).toString())));
			out.write("</td></tr>");
		}
		%>		
		</table>
		</td>
	</tr>
	</table>	
	<%}%>
<br/>	
</fieldset>
</div>
</div>
</body>
</html>